<?php

	//获取直拨话机接口-get_sip_phone.php
	//create by L
	//http://42.121.57.193:7788/platform/get_sip_phone.php?phone=13011112222
	//成功返回0|vos的ip|直拨话机号码|直拨话机密码|被叫改写规则

	include_once "init.php";

	$phone_num 		= $_GET["phone"];

	//检测参数
	if(''==$phone_num)
	{
		die("-1|手机号码不可以为空");
	}

	if (strlen($phone_num) != 11 || false==is_numeric($phone_num) || ord($phone_num)!=49)
	{
		die("-1|手机号码必须是11位数字，并且以1开头");
	}

	$con    = db_connect(DB_NAME);
	$res = mysql_query("SELECT sipline_id,sip_account,sip_pwd from user where phone='$phone_num'") or die("-1|查询数据库失败");
	$row = mysql_fetch_row($res);

	//检测用户是否存在
	if (empty($row))
	{
		mysql_close($con);
		die("-1|该手机号码未注册");
	}

	mysql_close($con);
	$rewrite_rule		= $sipline_config[$row[0]]["precode"];

	//--输出
	echo '0|'.VOS_HOST.'|'.$row[1].'|'.$row[2].'|'.$rewrite_rule;
?>